<template lang="html">
  <div class="box">
      <div class="header">
          <el-form class="filterCondition demo-form-inline" :inline="true" label-width="80px">
              <el-input placeholder="输入车主姓名/设备号/联系方式" v-model="keyword" style="width: 420px;">
                <el-button slot="append" style="width: 120px;" @click="search()">搜索</el-button>
              </el-input>
          </el-form>
      </div>

      <div class="body">
          <el-table :data="tableData.list" style="width: 100%">
              <el-table-column label="车主姓名" prop="name" align="center" width=""></el-table-column>
              <el-table-column label="联系方式" prop="phone" align="center" width=""></el-table-column>
              <el-table-column label="设备号" prop="eq_num" align="center" width=""></el-table-column>
              <el-table-column label="设备号状态" align="center" width="">
                  <template slot-scope="scope">
                      <el-popover trigger="hover" @show="onshow(scope.row)" placement="top">
                        <!-- <p>运行中: {{ scope.row.name }}</p>
                        <p>熄火: {{ scope.row.address }}</p>
                        <p>异常: {{ scope.row.address }}</p> -->
                        <p>{{eqStatus}}</p>
                        <el-button type="primary" slot="reference" plain size="mini">查看详情</el-button>
                      </el-popover>
                  </template>
              </el-table-column>
          </el-table>
      </div>

      <div class="page_box">
          <el-pagination class="page" layout="prev, pager, next"
            @current-change="switchPage" :current-page="currentPage" :page-count='tableData.rows' >
          </el-pagination>
      </div>
  </div>
</template>

<script>
export default {
  data(){
    return {
      keyword:'',
      tableData:[],
      eqStatus:'',
      currentPage:1
    }
  },
  created(){
    this.bbyObdList()
  },
  methods:{
    search(){
      this.bbyObdList()
    },
    bbyObdList(page=1){
      this.currentPage = page;
      this.$http4.bbyObdList({key:this.keyword})
      .then(res=>{
        this.tableData = res.data.code == 1?
        res.data.data:[]
      })
    },
    onshow(e){
        this.eqStatus = ''
        this.$http4.bbyMIsOBD({
          eq_name:e.eq_num,
          unionId:e.unionId
        }).then(res=>{
          this.eqStatus = res.data.data.list.status
        })
    },
    switchPage(p){
      this.bbyObdList(p)
    }
  }
}
</script>

<style lang="css" scoped>
@import "../../../my-style/app.css";

/deep/ .el-input-group__append, .el-input-group__prepend{
  background-color: #3498E9;
  border: none;
  color: white;
}

.preview-img{
  display: inline-block;
  width: 50px;
  height: 50px;
  border-radius: 100%;
  overflow: hidden;
}
.header{
  margin-bottom: 10px
}
.page_box{
  text-align: center;
}
</style>
